#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 200005
using namespace std;
inline int read(){
	int x = 0, f = 1; char c = getchar();
	while(c < '0' || c > '9'){if(c == '-')f = -1; c = getchar();}
	while(c >= '0' && c <= '9'){x = (x << 1) + (x << 3) + c - '0'; c = getchar();}
	return x * f;
}
int n, l, r, a[N], b[N], cnt, tmp;
queue<int> q[N];
void lian(){
	if(l < 1 || r > cnt){
		return;
	}
	if(a[q[l].front()] == a[q[r].front()]){
		while(!q[r].empty()){
			q[l].push(q[r].front());
			q[r].pop();
		}
	}
	else{
		return;
	}
}
int main(){
	freopen("fruit.in", "r", stdin);
	freopen("fruit.out", "w", stdout);
	n = read();
	a[0] = -1;
	for(int i = 1; i <= n; ++i){
		a[i] = read();
		if(a[i - 1] != a[i]){
			q[++cnt].push(i);
		}
		else{
			q[cnt].push(i);
		}
	}
	tmp = cnt;
	while(tmp){
		for(int i = 1; i <= cnt; ++i){
			if(!q[i].empty()){
				printf("%d ", q[i].front());
				q[i].pop();
				if(q[i].empty()){
					l = 0, r = cnt + 1;
					for(int j = i - 1; j >= 1; --j){
						if(b[j]){
							l = j;
							break;
						}
					}
					for(int j = i + 1; j <= cnt; ++j){
						if(b[j]){
							r = j;
							break;
						}
					}
					lian();
					--tmp;
				}
			}
		}
		printf("\n");
	}
	return 0;
}
